define [
	'jquery'
	'sammy/plugins/sammy.template-0.7.1.min.js'
	'jquery.couch.js'
	'helper'
], ($, undef, undef, H) ->
	S = {}
	$.fn.mb_donor_detail = (SamCtx) ->

		$this = $(@)
		S = SamCtx
		return if  @mb_plugin()
		@mb_plugin 'donor_detail'
		$.subscribe(
			'mb.donor'
			(e, arg) ->
				donor_id = arg['donor_id']
				$.couch.db('vcn-members').openDoc(
					donor_id
					success: (data) ->
						content = S.content $('#tpl_detail').hide(), data
						$this.find('#content_detail').empty().append content
					error: (status) ->
						console.log(status)
						$.publish 'mb.error', 'Document is not open'
				)
		)
		### $(() ->###
		$this.find('input:text').editable()
	return @









